import App from './App'
import Vue from 'vue'
import VueI18n from 'vue-i18n'
// import * as RongIMLib from "@rongcloud/imlib-next";
// import config from './config/app.config'
import store from './store'
import uView from '@/uni_modules/uview-ui'
// 引入全局方法
import mixin from './utils/mixin.js'
// import RongIMEmoji from './utils/RongEmoji-2.2.10'
// 引入融云
import RongIMLib from './utils/initRongIM.js'
// i18n
import messages from './locale/index'
// 解决ios10+,禁止缩放失效问题
import './utils/noScale.js'
import { rewirteLog } from '@/utils/common.js'
import hljs from 'highlight.js';


rewirteLog()

let i18nConfig = {
  locale: uni.getLocale(),
  messages
}
App.mpType = 'app'
Vue.prototype.$RongIMLib = RongIMLib
Vue.prototype.$RongIMEmoji = RongIMLib.RongIMEmoji
Vue.prototype.$store = store

// RongIMLib.init({ appkey: config.RongIMAppKey ,logOutputLevel:4});

// RongIMLib.RongIMEmoji = RongIMEmoji
// RongIMLib.RongIMEmoji.init()
// RongIMLib.RongIMEmoji.list
// console.log('列表',RongIMLib.RongIMEmoji.list);
// Vue.prototype.$RongIMLib = RongIMLib
Vue.use(uView)
Vue.mixin(mixin) 
Vue.use(VueI18n)
Vue.use(hljs);
const i18n = new VueI18n(i18nConfig)
Vue.config.productionTip = false
//封装成一个指令,highlight是指令的名称
Vue.directive('highlight', (el) => {
  let blocks = el.querySelectorAll('pre code')
  blocks.forEach((block) => {
    // // 创建ol标签元素
    // let ol = document.createElement("ol");
    // // 2.根据换行符获取行数，根据获取的行数生成行号
    // let rowCount = block.outerHTML.split('\n').length;
    // for (let i = 1; i < rowCount; i++) {
    //   // 创建li标签元素
    //   let li = document.createElement("li");
    //   let text = document.createTextNode(i);
    //   // 将生成的行号添加到li标签中
    //   li.appendChild(text);
    //   // 将li标签添加到ol标签中
    //   ol.appendChild(li);
    // }
    // // 为ol标签添加class名
    // ol.className = 'pre-numbering';
    // block.parentNode.appendChild(ol);
    hljs.highlightBlock(block)
  })
})
App.mpType = 'app'
const vueMain = new Vue({
  i18n,
  ...App
})
vueMain.$mount()

export { i18n }
export default vueMain